﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>企业员工记录</title>
    <!--link to style-->
    <link rel="stylesheet" href="css/adapt.css" />
    <link rel="stylesheet" href="../css/bootstrap.min.css" />
    <link rel="stylesheet" href="../css/font-awesome.min.css" />
    <!--<link rel="stylesheet" href="css/adapt.css" />-->
    <!--//End link to style-->
    <script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>
    <div class="Body clearfix">
        <div class="catlog">
            <span class="cat_block">当前位置</span>
            <span class="cat_block icon-chevron-right">员工记录</span>
            <span class="cat_block icon-chevron-right">重置员工薪资</span>
        </div>
        <div class="archt">
            <form method="post" action="">
                <div class="arc_line">
                    <span class="arc_tit">员工号：</span>
                    <input class="atc_input" type="text" name="sNo" readonly="readonly" id="sno"/>
                </div>
                <div class="arc_line">
                    <span class="arc_tit">员工名：</span>
                    <input class="atc_input" type="text" name="sName" readonly="readonly" id="sname"/>
                </div>
                <div class="arc_line">
                    <span class="arc_tit">薪资：</span>
                    <input class="atc_input" type="text" name="sSalary" id="ssalary"/>
                </div>
                <input class="submit" type="button" value="提交" />
            </form>
        </div>
        
    </div>



    <script>
        $(function () {

        	//获取地址链接问号后面参数的值
            //url  地址 getUrl(location.href).Id;
            getUrl = function (url) {
                url = !url ? location.search : url;
                var temp = {};
                if (url.indexOf("?") != -1) {
                    var params = url.substr(url.indexOf("?") + 1).split("&");
                    for (var i = 0; i < params.length; i++) {
                        var param = params[i].split("=");
                        temp[param[0]] = param[1];
                    }
                    return temp;
                } else {
                    return false;
                }
            }
            var id = getUrl(location.href).id;
            
            $.ajax({
                type: "Post",
                url: "/hr_doc/servlet/StaffServlet",
                data: {
               	 Command:"load",
               	 id:id
                },
                async: false,
                dataType: "json",
                success: function (d) {
					console.log(d);
	               	if(d.code == 1){
	               		var result = d.result;
	               		$("#sno").val(result.sno);
	               		$("#sname").val(result.sname);
	               		
	               	}
                },
                error: function (xmlHttpRequest, textStatus, errorThrown) {
                	
                }
            });
            
            $(".submit").click(function(){
            	$.ajax({
                    type: "Post",
                    url: "/hr_doc/servlet/StaffServlet",
                    data: {
                   	 Command:"modify",
                   	 id:id,
                   	 sminsalary:$("#ssalary").val()
                    },
                    async: false,
                    dataType: "json",
                    success: function (d) {
    					console.log(d);
    	               	if(d.code == 1){
    	               		alert("修改成功");
    	               		location.href = "/hr_doc/subPage/staffRecord.html";
    	               	}
                    },
                    error: function (xmlHttpRequest, textStatus, errorThrown) {
                    	
                    }
                });
            	
            	
            	
            });
            
        	
        })
    </script>
</body>
</html>